﻿using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using ZFSDomain.Common.UserControls;
using ZFSDomain.Interface.Base;
using ZFSDomain.Interface.User;
using ZFSDomain.ViewModel.Step;

namespace ZFSDomain.ViewDialog.Step
{
    public class SkinViewDlg : ISkinDialog
    {
        /// <summary>
        /// 关联窗口
        /// </summary>
        private SkinWindow view;
        
        /// <summary>
        /// 绑定数据上下文对象
        /// </summary>
        /// <typeparam name="TViewModel"></typeparam>
        /// <param name="viewModel"></param>
        public void BindViewModel<TViewModel>(TViewModel viewModel) where TViewModel : ViewModelBase
        {
            this.GetDialog().DataContext = viewModel;
        }

        /// <summary>
        /// 关闭窗口
        /// </summary>
        public void Close()
        {
            this.GetDialog().Close();
        }

        /// <summary>
        /// 打开窗口
        /// </summary>
        /// <returns></returns>
        public bool? ShowDialog()
        {
            return this.GetDialog().ShowDialog();
        }


        /// <summary>
        /// 获取窗口实例
        /// </summary>
        /// <returns></returns>
        public SkinWindow GetDialog()
        {
            if (view == null)
            {
                view = new SkinWindow();
            }
            return view;
        }
        
    }
}
